package com.wxgo.controller.admin;

import java.util.List;

import com.jfinal.core.Controller;
import com.wxgo.common.model.Fmenu;
import com.wxgo.factory.DaoFactory;

public class FmenuController extends Controller {

	public void manage() {
		List<Fmenu> fmenuList = DaoFactory.fmenuDao().find("select * from fmenu");
		setAttr("tableList", fmenuList);
		render("/admin/fmenu/fmenuManage.html");
	}

	public void add() {
		render("/admin/fmenu/fmenuAdd.html");
	}

	public void save() {
		Fmenu fmenu = getModel(Fmenu.class, "fmenu");
		fmenu.save();
		manage();
		return;
	}

	public void delete() {
		String id = getPara("id");
		DaoFactory.fmenuDao().delete("fmenu", id);
		manage();
	}

	public void edit() {
		Integer id = getParaToInt("id");
		Fmenu fmenu = DaoFactory.fmenuDao().findById(id);
		setAttr("fmenu", fmenu);
		render("/admin/fmenu/fmenuEdit.html");
	}

	public void update() {
		Fmenu fmenu = getModel(Fmenu.class, "fmenu");
		fmenu.update();
		manage();
		return;
	}
}
